@extends('admin::layouts.master')
@section('title')
    角色列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">

                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加角色','{{route("admin_role_create")}}',800,600)"><i class="layui-icon"></i>添加</button>
                        <a class="layui-btn" onclick="location.reload()">
                            <i class="layui-icon layui-icon-refresh"></i>
                        </a>

                    </div>
                    <div class="layui-card-body layui_overflow_y">

                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>ID</th>
                                <th>角色名称</th>
                                <th>角色别名</th>
                                <th>状态</th>
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                                <tr>
                                    <td>{{$key+1}}</td>
                                    <td>{{$value["id"]}}</td>
                                    <td>{{$value["name"]}}</td>
                                    <td>{{$value["display_name"]}}</td>
                                    <td>
                                        @if($value["status"] === 1)
                                            <input type="checkbox" name="switch" data_attr='{"id":"{{$value['id']}}","field_name":"status","url":"{{route("admin_role_change_state")}}"}'  lay-text="开启|停用" lay-filter="change_state" checked="" lay-skin="switch">
                                        @else
                                            <input type="checkbox" name="switch" data_attr='{"id":"{{$value['id']}}","field_name":"status","url":"{{route("admin_role_change_state")}}"}' lay-text="开启|停用" lay-filter="change_state" lay-skin="switch">
                                        @endif

                                    </td>
                                    <td class="td-manage">
                                        <button class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('修改角色','{{route("admin_role_edit",["id"=>$value["id"]])}}')" ><i class="layui-icon">&#xe642;</i>修改</button>
                                        {{--<button class="layui-btn-danger layui-btn layui-btn-xs ajax_member_del" data-href="{{route('admin_role_delete',['id'=>$value['id']])}}" data-title="确定删除角色吗？请谨慎操作" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>--}}
                                    </td>
                                </tr>

                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>

                        {{--     <div class="page">
                                 <div>
                                     <a class="prev" href="">&lt;&lt;</a>
                                     <a class="num" href="">1</a>
                                     <span class="current">2</span>
                                     <a class="num" href="">3</a>
                                     <a class="num" href="">489</a>
                                     <a class="next" href="">&gt;&gt;</a></div>
                             </div>--}}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('tab_js')
    <script>
        layui.use(['form'], function(){
            var form = layui.form;

            //监听指定开关-修改状态
            form.on('switch(change_state)',
                function(obj){
                    change_state(this);
                    // layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                    //     offset: '60px'
                    // });
                    // layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', obj.othis)
                });
        });
    </script>
@endsection




